DAY10:Is this a triangle?


Posted by birdbirdmurmur on 2023-07-23

題目連結:

Is this a triangle?

解法:

暴力解法

function isTriangle(a,b,c) {
if (a + b > c && a + c > b && b + c > a) {
  return true; 
}
  return false;
}

簡潔解法

function isTriangle(a,b,c){
   return a + b > c && a + c > b && c + b > a;
}

心得筆記:

這題很簡單
就是很基本的判斷三角形是否成立
值得學習的是使用更簡潔的回傳方式


#javascript #Codewars







Related Posts

筆記、[FE101] 前端基礎 各種裝飾

筆記、[FE101] 前端基礎 各種裝飾

[ 紀錄 ] 實戰練習 - 抽獎程式 (以 Express 實作後端 API )

[ 紀錄 ] 實戰練習 - 抽獎程式 (以 Express 實作後端 API )

XSS lab (1)

XSS lab (1)


Comments